/*
 * @Description: 路由
 * @Date: 2021-04-15 11:11:25 +0800
 * @Author: JackChou
 * @LastEditTime: 2021-04-16 10:33:52 +0800
 * @LastEditors: JackChou
 */
import { App } from '../model'
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import settingsRoutes from '../views/settings/routes'
const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'index',
    component: () => import('../views/index.vue'),
    children: [
      {
        path: '', // NOTE path 为 '' 否则 路径为 / 时，不会渲染 home 组件
        name: 'home',
        component: () => import('../views/home/index.vue'),
      },
      ...settingsRoutes,
    ],
  },
]
const router = createRouter({
  history: createWebHashHistory(),
  routes,
})
export const setupRouter = (app: App) => {
  app.use(router)
  return app
}
